﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using DAL;

namespace QuanLyBilliards_Coffee
{
    public partial class FormThemBanCafe : Form
    {
        BanRepository ban = new BanRepository();
        public FormThemBanCafe()
        {
            InitializeComponent();
        }

        private void btnThemBanCF_Click(object sender, EventArgs e)
        {
            Ban b = new Ban();
            string tenban = null;
            string t = txtTenBanCF.Text;
            string loai = null;
            if (rdbanBinhThuongCF.Checked)
            {
                loai = "Bình thường";
                tenban = t + "BT";
            }
            else
            {
                loai = "Vip";
                tenban = t + "Vip";
            }
            bool tt = false;//dang rảnh
            int gia = 0;
            bool l = true;
            b.LoaiBan = loai;
            b.TrangThai = tt;
            b.Gia = gia;
            b.Cafe = l;
            b.TenBan = tenban;
            Ban a = ban.GetByTenBan(tenban);
            if (a != null && a.Cafe == true)
            {
                MessageBox.Show("Bàn đã tồn tại");
                txtTenBanCF.Text = "";

            }
            else
            {
                if (ban.AddNew(b))
                {
                    MessageBox.Show("Thêm thành công");
                    txtTenBanCF.Text = "";
                    rdbanBinhThuongCF.Checked = false;
                    // rdbanVIPCF.Checked = false;
                }
                else
                {
                    MessageBox.Show("Lỗi");
                    txtTenBanCF.Text = "";
                    rdbanBinhThuongCF.Checked = false;
                }
            }

           
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FormThemBanCafe_Load(object sender, EventArgs e)
        {

        }
    }
}
